/*
 * Ext JS Library 3.0 RC2
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */


Ext.Tip=Ext.extend(Ext.Panel,{minWidth:40,maxWidth:300,shadow:"sides",defaultAlign:"tl-bl?",autoRender:true,quickShowInterval:250,frame:true,hidden:true,baseCls:'x-tip',floating:{shadow:true,shim:true,useDisplay:true,constrain:false},autoHeight:true,closeAction:'hide',initComponent:function(){Ext.Tip.superclass.initComponent.call(this);if(this.closable&&!this.title){this.elements+=',header';}},afterRender:function(){Ext.Tip.superclass.afterRender.call(this);if(this.closable){this.addTool({id:'close',handler:this[this.closeAction],scope:this});}},showAt:function(xy){Ext.Tip.superclass.show.call(this);if(this.measureWidth!==false&&(!this.initialConfig||typeof this.initialConfig.width!='number')){this.doAutoWidth();}
if(this.constrainPosition){xy=this.el.adjustForConstraints(xy);}
this.setPagePosition(xy[0],xy[1]);},doAutoWidth:function(){var bw=this.body.getTextWidth();if(this.title){bw=Math.max(bw,this.header.child('span').getTextWidth(this.title));}
bw+=this.getFrameWidth()+(this.closable?20:0)+this.body.getPadding("lr");this.setWidth(bw.constrain(this.minWidth,this.maxWidth));if(Ext.isIE7&&!this.repainted){this.el.repaint();this.repainted=true;}},showBy:function(el,pos){if(!this.rendered){this.render(Ext.getBody());}
this.showAt(this.el.getAlignToXY(el,pos||this.defaultAlign));},initDraggable:function(){this.dd=new Ext.Tip.DD(this,typeof this.draggable=='boolean'?null:this.draggable);this.header.addClass('x-tip-draggable');}});Ext.Tip.DD=function(tip,config){Ext.apply(this,config);this.tip=tip;Ext.Tip.DD.superclass.constructor.call(this,tip.el.id,'WindowDD-'+tip.id);this.setHandleElId(tip.header.id);this.scroll=false;};Ext.extend(Ext.Tip.DD,Ext.dd.DD,{moveOnly:true,scroll:false,headerOffsets:[100,25],startDrag:function(){this.tip.el.disableShadow();},endDrag:function(e){this.tip.el.enableShadow(true);}});

Ext.ToolTip=Ext.extend(Ext.Tip,{showDelay:500,hideDelay:200,dismissDelay:5000,trackMouse:false,anchorToTarget:true,anchorOffset:0,targetCounter:0,constrainPosition:false,initComponent:function(){Ext.ToolTip.superclass.initComponent.call(this);this.lastActive=new Date();this.initTarget(this.target);this.origAnchor=this.anchor;},onRender:function(ct,position){Ext.ToolTip.superclass.onRender.call(this,ct,position);this.anchorCls='x-tip-anchor-'+this.getAnchorPosition();this.anchorEl=this.el.createChild({cls:'x-tip-anchor '+this.anchorCls});},afterRender:function(){Ext.ToolTip.superclass.afterRender.call(this);this.anchorEl.setStyle('z-index',this.el.getZIndex()+1);},initTarget:function(target){var t;if((t=Ext.get(target))){if(this.target){this.target=Ext.get(this.target);this.target.un('mouseover',this.onTargetOver,this);this.target.un('mouseout',this.onTargetOut,this);this.target.un('mousemove',this.onMouseMove,this);}
this.mon(t,{mouseover:this.onTargetOver,mouseout:this.onTargetOut,mousemove:this.onMouseMove,scope:this});this.target=t;}
if(this.anchor){this.anchorTarget=this.target;}},onMouseMove:function(e){var t=this.delegate?e.getTarget(this.delegate):this.triggerElement=true;if(t){this.targetXY=e.getXY();if(t===this.triggerElement){if(!this.hidden&&this.trackMouse){this.setPagePosition(this.getTargetXY());}}else{this.hide();this.lastActive=new Date(0);this.onTargetOver(e);}}else if(!this.closable&&this.isVisible()){this.hide();}},getTargetXY:function(){if(this.anchor){this.targetCounter++;var offsets=this.getOffsets();var xy=(this.anchorToTarget&&!this.trackMouse)?this.el.getAlignToXY(this.anchorTarget,this.getAnchorAlign()):this.targetXY;var dw=Ext.lib.Dom.getViewWidth()-5;var dh=Ext.lib.Dom.getViewHeight()-5;var scrollX=(document.documentElement.scrollLeft||document.body.scrollLeft||0)+5;var scrollY=(document.documentElement.scrollTop||document.body.scrollTop||0)+5;var axy=[xy[0]+offsets[0],xy[1]+offsets[1]];var sz=this.getSize();this.anchorEl.removeClass(this.anchorCls);if(this.targetCounter<2){if(axy[0]<scrollX){if(this.anchorToTarget){this.defaultAlign='l-r';if(this.mouseOffset){this.mouseOffset[0]*=-1;}}
this.anchor='left';return this.getTargetXY();}
if(axy[0]+sz.width>dw){if(this.anchorToTarget){this.defaultAlign='r-l';if(this.mouseOffset){this.mouseOffset[0]*=-1;}}
this.anchor='right';return this.getTargetXY();}
if(axy[1]<scrollY){if(this.anchorToTarget){this.defaultAlign='t-b';if(this.mouseOffset){this.mouseOffset[1]*=-1;}}
this.anchor='top';return this.getTargetXY();}
if(axy[1]+sz.height>dh){if(this.anchorToTarget){this.defaultAlign='b-t';if(this.mouseOffset){this.mouseOffset[1]*=-1;}}
this.anchor='bottom';return this.getTargetXY();}}
this.anchorCls='x-tip-anchor-'+this.getAnchorPosition();this.anchorEl.addClass(this.anchorCls);this.targetCounter=0;return axy;}else{var mouseOffset=this.getMouseOffset();return[this.targetXY[0]+mouseOffset[0],this.targetXY[1]+mouseOffset[1]];}},getMouseOffset:function(){var offset=this.anchor?[0,0]:[15,18];if(this.mouseOffset){offset[0]+=this.mouseOffset[0];offset[1]+=this.mouseOffset[1];}
return offset;},getAnchorPosition:function(){if(this.anchor){this.tipAnchor=this.anchor.charAt(0);}else{var m=this.defaultAlign.match(/^([a-z]+)-([a-z]+)(\?)?$/);if(!m){throw"AnchorTip.defaultAlign is invalid";}
this.tipAnchor=m[1].charAt(0);}
switch(this.tipAnchor){case't':return'top';case'b':return'bottom';case'r':return'right';}
return'left';},getAnchorAlign:function(){switch(this.anchor){case'top':return'tl-bl';case'left':return'tl-tr';case'right':return'tr-tl';default:return'bl-tl';}},getOffsets:function(){var offsets,ap=this.getAnchorPosition().charAt(0);if(this.anchorToTarget&&!this.trackMouse){switch(ap){case't':offsets=[0,9];break;case'b':offsets=[0,-13];break;case'r':offsets=[-13,0];break;default:offsets=[9,0];break;}}else{switch(ap){case't':offsets=[-15-this.anchorOffset,30];break;case'b':offsets=[-19-this.anchorOffset,-13-this.el.dom.offsetHeight];break;case'r':offsets=[-15-this.el.dom.offsetWidth,-13-this.anchorOffset];break;default:offsets=[25,-13-this.anchorOffset];break;}}
var mouseOffset=this.getMouseOffset();offsets[0]+=mouseOffset[0];offsets[1]+=mouseOffset[1];return offsets;},onTargetOver:function(e){if(this.disabled||e.within(this.target.dom,true)){return;}
var t=e.getTarget(this.delegate);if(t){this.triggerElement=t;this.clearTimer('hide');this.targetXY=e.getXY();this.delayShow();}},delayShow:function(){if(this.hidden&&!this.showTimer){if(this.lastActive.getElapsed()<this.quickShowInterval){this.show();}else{this.showTimer=this.show.defer(this.showDelay,this);}}else if(!this.hidden&&this.autoHide!==false){this.show();}},onTargetOut:function(e){if(this.disabled||e.within(this.target.dom,true)){return;}
this.clearTimer('show');if(this.autoHide!==false){this.delayHide();}},delayHide:function(){if(!this.hidden&&!this.hideTimer){this.hideTimer=this.hide.defer(this.hideDelay,this);}},hide:function(){this.clearTimer('dismiss');this.lastActive=new Date();delete this.triggerElement;if(this.anchorEl){this.anchorEl.hide();}
Ext.ToolTip.superclass.hide.call(this);},show:function(){if(this.anchor){this.showAt([-1000,-1000]);this.origConstrainPosition=this.constrainPosition;this.constrainPosition=false;this.anchor=this.origAnchor;}
this.showAt(this.getTargetXY());if(this.anchor){this.syncAnchor();this.anchorEl.show();this.constrainPosition=this.origConstrainPosition;}else{this.anchorEl.hide();}},showAt:function(xy){this.lastActive=new Date();this.clearTimers();Ext.ToolTip.superclass.showAt.call(this,xy);if(this.dismissDelay&&this.autoHide!==false){this.dismissTimer=this.hide.defer(this.dismissDelay,this);}},syncAnchor:function(){var anchorPos,targetPos,offset;switch(this.tipAnchor.charAt(0)){case't':anchorPos='b';targetPos='tl';offset=[20+this.anchorOffset,2];break;case'r':anchorPos='l';targetPos='tr';offset=[-2,11+this.anchorOffset];break;case'b':anchorPos='t';targetPos='bl';offset=[20+this.anchorOffset,-2];break;default:anchorPos='r';targetPos='tl';offset=[2,11+this.anchorOffset];break;}
this.anchorEl.alignTo(this.el,anchorPos+'-'+targetPos,offset);},setPagePosition:function(x,y){Ext.ToolTip.superclass.setPagePosition.call(this,x,y);if(this.anchor){this.syncAnchor();}},clearTimer:function(name){name=name+'Timer';clearTimeout(this[name]);delete this[name];},clearTimers:function(){this.clearTimer('show');this.clearTimer('dismiss');this.clearTimer('hide');},onShow:function(){Ext.ToolTip.superclass.onShow.call(this);Ext.getDoc().on('mousedown',this.onDocMouseDown,this);},onHide:function(){Ext.ToolTip.superclass.onHide.call(this);Ext.getDoc().un('mousedown',this.onDocMouseDown,this);},onDocMouseDown:function(e){if(this.autoHide!==true&&!this.closable&&!e.within(this.el.dom)){this.disable();this.enable.defer(100,this);}},onDisable:function(){this.clearTimers();this.hide();},adjustPosition:function(x,y){if(this.contstrainPosition){var ay=this.targetXY[1],h=this.getSize().height;if(y<=ay&&(y+h)>=ay){y=ay-h-5;}}
return{x:x,y:y};},onDestroy:function(){Ext.getDoc().un('mousedown',this.onDocMouseDown,this);Ext.ToolTip.superclass.onDestroy.call(this);}});

Ext.QuickTip=Ext.extend(Ext.ToolTip,{interceptTitles:false,tagConfig:{namespace:"ext",attribute:"qtip",width:"qwidth",target:"target",title:"qtitle",hide:"hide",cls:"qclass",align:"qalign",anchor:"anchor"},initComponent:function(){this.target=this.target||Ext.getDoc();this.targets=this.targets||{};Ext.QuickTip.superclass.initComponent.call(this);},register:function(config){var cs=Ext.isArray(config)?config:arguments;for(var i=0,len=cs.length;i<len;i++){var c=cs[i];var target=c.target;if(target){if(Ext.isArray(target)){for(var j=0,jlen=target.length;j<jlen;j++){this.targets[Ext.id(target[j])]=c;}}else{this.targets[Ext.id(target)]=c;}}}},unregister:function(el){delete this.targets[Ext.id(el)];},onTargetOver:function(e){if(this.disabled){return;}
this.targetXY=e.getXY();var t=e.getTarget();if(!t||t.nodeType!==1||t==document||t==document.body){return;}
if(this.activeTarget&&t==this.activeTarget.el){this.clearTimer('hide');this.show();return;}
if(t&&this.targets[t.id]){this.activeTarget=this.targets[t.id];this.activeTarget.el=t;this.anchor=this.activeTarget.anchor;if(this.anchor){this.anchorTarget=t;}
this.delayShow();return;}
var ttp,et=Ext.fly(t),cfg=this.tagConfig;var ns=cfg.namespace;if(this.interceptTitles&&t.title){ttp=t.title;t.qtip=ttp;t.removeAttribute("title");e.preventDefault();}else{ttp=t.qtip||et.getAttribute(cfg.attribute,ns);}
if(ttp){var autoHide=et.getAttribute(cfg.hide,ns);this.activeTarget={el:t,text:ttp,width:et.getAttribute(cfg.width,ns),autoHide:autoHide!="user"&&autoHide!=='false',title:et.getAttribute(cfg.title,ns),cls:et.getAttribute(cfg.cls,ns),align:et.getAttribute(cfg.align,ns)};this.anchor=et.getAttribute(cfg.anchor,ns);if(this.anchor){this.anchorTarget=t;}
this.delayShow();}},onTargetOut:function(e){this.clearTimer('show');if(this.autoHide!==false){this.delayHide();}},showAt:function(xy){var t=this.activeTarget;if(t){if(!this.rendered){this.render(Ext.getBody());this.activeTarget=t;}
if(t.width){this.setWidth(t.width);this.body.setWidth(this.adjustBodyWidth(t.width-this.getFrameWidth()));this.measureWidth=false;}else{this.measureWidth=true;}
this.setTitle(t.title||'');this.body.update(t.text);this.autoHide=t.autoHide;this.dismissDelay=t.dismissDelay||this.dismissDelay;if(this.lastCls){this.el.removeClass(this.lastCls);delete this.lastCls;}
if(t.cls){this.el.addClass(t.cls);this.lastCls=t.cls;}
if(this.anchor){this.constrainPosition=false;}else if(t.align){xy=this.el.getAlignToXY(t.el,t.align);this.constrainPosition=false;}else{this.constrainPosition=true;}}
Ext.QuickTip.superclass.showAt.call(this,xy);},hide:function(){delete this.activeTarget;Ext.QuickTip.superclass.hide.call(this);}});

Ext.QuickTips=function(){var tip,locks=[];return{init:function(autoRender){if(!tip){if(!Ext.isReady){Ext.onReady(function(){Ext.QuickTips.init(autoRender);});return;}
tip=new Ext.QuickTip({elements:'header,body'});if(autoRender!==false){tip.render(Ext.getBody());}}},enable:function(){if(tip){locks.pop();if(locks.length<1){tip.enable();}}},disable:function(){if(tip){tip.disable();}
locks.push(1);},isEnabled:function(){return tip!==undefined&&!tip.disabled;},getQuickTip:function(){return tip;},register:function(){tip.register.apply(tip,arguments);},unregister:function(){tip.unregister.apply(tip,arguments);},tips:function(){tip.register.apply(tip,arguments);}}}();
